/*
* Wander.h
*
*  Created on: Apr 8, 2014
*      Author: laventine5678
*/

#ifndef WANDER_H_
#define WANDER_H_

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <wiringPi.h>
#include <softPwm.h>
//#include <pthread.h>

#define L_MOTOR_PIN 7
#define R_MOTOR_PIN 0
#define L_SENSOR_PIN 3
#define R_SENSOR_PIN 2
#define LEFT_LED_PIN 1
#define RIGHT_LED_PIN 4
#define PWM_RANGE 100
#define TIMER_PIN 5 //TODO this is a placeholder for timer_pin's value
//chose 5 for now

int volatile GO_FLAG = 1;
int volatile CHECK_SONAR = 1;
int volatile R_FLAG = 1;
int TIMER = 0;
int direction = 1;
int L_PWM = 0;
int R_PWM = 0;

long microsecondsToInches(long);
void updateMotorValues();
int pulseIn(int, int, int);
void wander(int, int);
void checkSonar();
void detectCollision();
double calcTime();
void sendPulse(int);
void sonarISR();
void setup();

#endif /* WANDER_H_ */
